author: Rafael A. Irizarry transition: none
\[\mbox{Prob}(+\mid D)=0.99, \mbox{Prob}(-\mid \mbox{no } D)=0.99,\]
If we select a random person and they test positive, what is the probability that they have disease?
We write this as \(\mbox{Prob}(D\mid+)?\)
Cystic fibrosis rate is \(\mbox{Prob}(D) \approx 0.00025\)
\[ \mbox{Pr}(A|B) = \frac{\mbox{Pr}(B|A)\mbox{Pr}(A)}{\mbox{Pr}(B)} \]
\[ \begin{eqnarray*} \mbox{Prob}(D|+) & = & \frac{ P(+|D) \cdot P(D)} {\mbox{Prob}(+)} \\ & = & \frac{\mbox{Prob}(+|D)\cdot P(D)} {\mbox{Prob}(+|D) \cdot P(D) + \mbox{Prob}(+|\mbox{no } D) \mbox{Prob}(\mbox{no } D)} \\ \end{eqnarray*} \]
\[ \begin{eqnarray*} \mbox{Prob}(D|+) & = & \frac{ P(+|D) \cdot P(D)} {\mbox{Prob}(+)} \\ & = & \frac{\mbox{Prob}(+|D)\cdot P(D)} {\mbox{Prob}(+|D) \cdot P(D) + \mbox{Prob}(+|\mbox{no } D) \mbox{Prob}(\mbox{no } D)} \\ & = & \frac{0.99 \cdot 0.00025}{0.99 \cdot 0.00025 + 0.01 \cdot (.99975)} \\ & = & 0.02 \;\;\; \mbox{not} \; \; \; 0.99 \end{eqnarray*} \]
Assessment: Write a Monte Carlo simulation that shows this. Let’s go step-by-step. http://goo.gl/forms/JPFdaptfkv
B = 1000000 res = replicate(B,{ x = sample(c(0,1),1, replace = T, prob = c(1-1/4000, 1/4000)) test = sample(c(1-x, x), 1, replace = TRUE, prob = c(0.01 , 0.99)) c(x,test) } )
table(res[1,], res[2,]) sum(res[2,] == 1 & res[1,] == 1) / sum(res[2,] == 1)
c(x,test): * 0,0: TN * 1,1: TP * 0,1: FP * 1,0: FN